home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / timer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  7.0 KB  |  259 lines

  1. /*      TIMER.H
  2.  *
  3.  * TempoTimer
  4.  *
  5.  * $Id: timer.h,v 1.3 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __TIMER_H
  18. #define __TIMER_H
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24.  
  25. /****************************************************************************\
  26. *
  27. * Function:     int tmrGetScrSync(unsigned *scrSync);
  28. *
  29. * Description:  Calculates the screen synchronization value for timer
  30. *
  31. * Input:        unsigned *scrSync       pointer to screen synchronization
  32. *                                       value
  33. *
  34. * Returns:      MIDAS error code.
  35. *               Screen syncronization value used with tmrSyncScr() is stored
  36. *               in *scrSync.
  37. *
  38. \****************************************************************************/
  39.  
  40. int CALLING tmrGetScrSync(unsigned *scrSync);
  41.  
  42.  
  43.  
  44.  
  45. /****************************************************************************\
  46. *
  47. * Function:     int tmrInit(void);
  48. *
  49. * Description:  Initializes TempoTimer.
  50. *
  51. * Returns:      MIDAS error code
  52. *
  53. \****************************************************************************/
  54.  
  55. int CALLING tmrInit(void);
  56.  
  57.  
  58.  
  59.  
  60. /****************************************************************************\
  61. *
  62. * Function:     int tmrClose(void);
  63. *
  64. * Description:  Uninitializes TempoTimer. MUST be called if and ONLY if
  65. *               tmrInit() has been called.
  66. *
  67. * Returns:      MIDAS error code
  68. *
  69. \****************************************************************************/
  70.  
  71. int CALLING tmrClose(void);
  72.  
  73.  
  74.  
  75.  
  76. /****************************************************************************\
  77. *
  78. * Function:     int tmrPlaySD(SoundDevice *SD);
  79. *
  80. * Description:  Starts playing sound with a Sound Device ie. calling its
  81. *               Play() function in the update rate, which is set to
  82. *               50Hz.
  83. *
  84. * Input:        SoundDevice *SD         Sound Device that will be used
  85. *
  86. * Returns:      MIDAS error code.
  87. *
  88. \****************************************************************************/
  89.  
  90. int CALLING tmrPlaySD(SoundDevice *SD);
  91.  
  92.  
  93.  
  94.  
  95. /****************************************************************************\
  96. *
  97. * Function:     int tmrStopSD(void);
  98. *
  99. * Description:  Stops playing sound with the Sound Device.
  100. *
  101. * Returns:      MIDAS error code.
  102. *
  103. \****************************************************************************/
  104.  
  105. int CALLING tmrStopSD(void);
  106.  
  107.  
  108.  
  109.  
  110. /****************************************************************************\
  111. *
  112. * Function:     int tmrPlayMusic(void *play, int *playerNum);
  113. *
  114. * Description:  Starts playing music with the timer.
  115. *
  116. * Input:        void *play              Pointer to music playing function,
  117. *                                       must return MIDAS error codes
  118. *               int *playerNum          Pointer to player number, used
  119. *                                       for stopping music
  120. *
  121. * Returns:      MIDAS error code. Player number is written to *playerNum.
  122. *
  123. * Notes:        There can be a maximum of 16 music players active at the
  124. *               same time.
  125. *
  126. \****************************************************************************/
  127.  
  128. int CALLING tmrPlayMusic(int (CALLING *play)(), int *playerNum);
  129.  
  130.  
  131.  
  132.  
  133. /****************************************************************************\
  134. *
  135. * Function:     int tmrStopMusic(int playerNum);
  136. *
  137. * Description:  Stops playing music with the timer.
  138. *
  139. * Input:        int playerNum           Number of player to be stopped.
  140. *
  141. * Returns:      MIDAS error code
  142. *
  143. \****************************************************************************/
  144.  
  145. int CALLING tmrStopMusic(int playerNum);
  146.  
  147.  
  148.  
  149.  
  150. /****************************************************************************\
  151. *
  152. * Function:     int tmrSyncScr(unsigned sync, void (*preVR)(),
  153. *                   void (*immVR)(), void (*inVR)());
  154. *
  155. * Description:  Synchronizes the timer to screen refresh.
  156. *
  157. * Input:        unsigned sync           Screen synchronization value returned
  158. *                                       by tmrGetScrSync().
  159. *               void (*preVR)()         Pointer to the routine that will be
  160. *                                       called BEFORE Vertical Retrace
  161. *               void (*immVR)()         Pointer to the routine that will be
  162. *                                       called immediately after Vertical
  163. *                                       Retrace starts
  164. *               void (*inVR)()          Pointer to the routine that will be
  165. *                                       called some time during Vertical
  166. *                                       Retrace
  167. *
  168. * Returns:      MIDAS error code
  169. *
  170. * Notes:        preVR() and immVR() functions must be as short as possible
  171. *               and do nothing else than update counters or set some VGA
  172. *               registers to avoid timer synchronization problems. inVR()
  173. *               can take a longer time and can be used for, for example,
  174. *               setting the palette.
  175. *
  176. *               Remember to use the correct calling convention for the xxVR()
  177. *               routines! (pascal for Pascal programs, cdecl otherwise).
  178. *
  179. \****************************************************************************/
  180.  
  181. int CALLING tmrSyncScr(unsigned sync, void (CALLING *preVR)(),
  182.     void (CALLING *immVR)(), void (CALLING *inVR)());
  183.  
  184.  
  185.  
  186.  
  187. /****************************************************************************\
  188. *
  189. * Function:     int tmrStopScrSync(void);
  190. *
  191. * Description:  Stops synchronizing the timer to the screen.
  192. *
  193. * Returns:      MIDAS error code
  194. *
  195. \****************************************************************************/
  196.  
  197. int CALLING tmrStopScrSync(void);
  198.  
  199.  
  200.  
  201.  
  202. /****************************************************************************\
  203. *
  204. * Function:     int tmrSetUpdRate(unsigned updRate);
  205. *
  206. * Description:  Sets the timer update rate, ie. the rate at which the music
  207. *               playing routines are called
  208. *
  209. * Input:        unsigned updRate        updating rate, in 100*Hz (5000=50Hz)
  210. *
  211. * Returns:      MIDAS error code
  212. *
  213. \****************************************************************************/
  214.  
  215. int CALLING tmrSetUpdRate(unsigned updRate);
  216.  
  217.  
  218. #ifdef __cplusplus
  219. }
  220. #endif
  221.  
  222.  
  223. /****************************************************************************\
  224. *       enum tmrFunctIDs
  225. *       ----------------
  226. * Description:  ID numbers for TempoTimer functions
  227. \****************************************************************************/
  228.  
  229. enum tmrFunctIDs
  230. {
  231.     ID_tmrGetScrSync = ID_tmr,
  232.     ID_tmrInit,
  233.     ID_tmrClose,
  234.     ID_tmrPlaySD,
  235.     ID_tmrStopSD,
  236.     ID_tmrPlayMusic,
  237.     ID_tmrStopMusic,
  238.     ID_tmrSyncScr,
  239.     ID_tmrStopScrSync,
  240.     ID_tmrSetUpdRate
  241. };
  242.  
  243.  
  244.  
  245. #endif
  246.  
  247.  
  248. /*
  249.  * $Log: timer.h,v $
  250.  * Revision 1.3  1997/01/16 18:41:59  pekangas
  251.  * Changed copyright messages to Housemarque
  252.  *
  253.  * Revision 1.2  1996/07/13 18:09:09  pekangas
  254.  * Fixed to compile with Visual C
  255.  *
  256.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  257.  * Initial revision
  258.  *
  259. */